#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
#include<string.h>
#define MAX_COMMANDS 2000
#ifndef REG_INCLUDED
    #define REG_INCLUDED
    enum REGISTERS{AX= -1004, BX, CX, DX};
#endif
#ifndef COM_INCLUDED
    #define COM_INCLUDED
    enum COMMANDS{
        PUSH = -10014,
        POP = -10013,
        MOV = -10012,
        ADD = -10011,
        SUB = -10010,
        MUL = -10009,
        DIVI = -10008,
        DUB = -10007,
        JB = -10006,
        JA = -10005,
        JE = -10004,
        QUIT = -10003,
        SQRTI = -10002,
        SKIP = -10001,
        CALL = -10000,
        FUNC = -9999,
        CALLA = -9998
    };
    struct command
    {
        int command;
        int valueType;
        double value;
    };
    struct label
    {
        int position;
        char name[20];
    };
    struct variable
    {
        char name[20];
        double value;
    };

    struct program
    {
        struct command com[2000];
        struct label labels[50];
        struct variable var[50];

        int length;
        int numofVar;
        int numofLabels;
    };
#endif // COM_INCLUDED
//<0 for type, >= 0 for varNumber
#ifndef VALUE_TYPE_INC
    #define VALUE_TYPE_INC
    enum VALUE_TYPE{NUMBER = -10, VARIABLE, OUTPUT};
#endif




int registerWriter(FILE* f_ass, char reg);
program* assemble(FILE* f);
int numVar  (program* prgr, char value[]);
int numLabel(program* prgr, char value[]);
void printCommands(const program* prgr);
